#include "../gEngine/IDevice.hpp"
#include "../gEngine/Logger.hpp"
#pragma comment( lib, "gEngine.lib" )
using namespace ge;

bool _exit_loop = false;
void OnWindowActivating( bool _activate )
{
     geLogMsg( "window activate: %d", _activate );
}

void OnWindowMove( int _x, int _y, Window::ShowType _show )
{
     geLogMsg( "window move: %d %d (st=%d)", _x, _y, _show );
}

void OnWindowResize( uint _width, uint _height, Window::ShowType _show )
{
     geLogMsg( "window resize: %u %u (st=%d)", _width, _height, _show );
}

void OnWindowClose( void )
{
     geLogMsg( "window try exit" );
     _exit_loop = true;
}
void OnKeyboardFocus( bool _focus )
{
     geLogMsg( "keyboard focus: %d", _focus );
}

void OnKeyboardKey( Keyboard::Key _key, int _action, char _ch )
{
     geLogMsg( "keyboard key: %u(%c) %u", _key, _ch, _action );
     if( _key == Keyboard::Key_Escape && _action == 0 ) _exit_loop = true;
}

void main( void )
{
     IDevice* _device = IDevice::CreateInstance();
     _device -> AddRef();
     _device -> SetWindowCallbacks( OnWindowActivating, OnWindowMove, OnWindowResize, OnWindowClose );
     _device -> SetKeyboardCallbacks( OnKeyboardFocus, OnKeyboardKey );
     //_device -> SetResizable( false );
     _device -> ResizeWindow( 320, 240 );
     _device -> MoveWindow( 100, 100 );
     _device -> SetShowType( Window::ShowType_Maximized );
     _device -> SetShowType( Window::ShowType_Minimized );
     //_device -> SetFullscreen( true );
     _device -> SetShow( true );

     while( !_exit_loop )
     {
          _device -> Process( 0 );
     }

}